home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / CC_C / 0294.ZIP / M_COFACT.C < prev    next >
C/C++ Source or Header  |  1985-05-18  |  4KB  |  26 lines

  1. static char *sccsid = "@(#)m_cofactor.c    4/5/82 (U of Maryland, FLB)";
  2.  
  3. #include "mat.h"
  4.  
  5. double
  6. m_cofactor(mat, i, j)
  7. register struct matrix *mat;
  8. register int i, j;
  9. {
  10. register struct matrix *result;
  11. register int row, col, o_row = 0, o_col = 0;
  12. double det;
  13.  
  14. m_create(result, mat->m_rows - 1, mat->m_cols - 1);
  15.  
  16. for (row = 0; row < mat->m_rows; row++)
  17.     for (col = 0; col < mat->m_cols; col++)
  18.         if (row != i && col != j)
  19.             m_v(result, o_row++, o_col++) = m_v(mat, row, col);
  20.  
  21. det = m_determinant(result);
  22. free(result);
  23.  
  24. return(((i + j) & 01)? -det: det);
  25. }